Source for file date.php
Documentation is available at date.php
Jalali Date function by Milad Rastian (miladmovie AT yahoo DOT com)
//The main function which convert Gregorian to Jalali calendars is:
// Copyright (C) 2000 Roozbeh Pournader and Mohammad Toossi
//you can see complete note of those function in down of the page
this function is simillar than date function in PHP
you can find more about it in http://jdf.farsiprojects.com
Copyright (C)2003 FARSI PROJECTS GROUP
// //\\ // //\\ // //////
\\ // /////\\\\\ // /////\\\\\ // //
\\// // \\ /////// // \\ ////////// /////
/////// //\\ ////// ////////
//////// // \\ // /////////
function jdate($type,$maket=
"now",$tran=
"")
//set 1 if you want translate number to farsi or if you don't like set 0
$maket+=
$TZhours*
3600+
$TZminute*
60;
$date=
date("Y-m-d",$maket);
list
( $year, $month, $day ) =
preg_split ( '/-/', $date );
$result1=
date("a",$need);
if($result1==
"pm") $result.=
"بعدازظهر";
else $result.=
"قبل‏ازظهر";
$result1=
date("a",$need);
if($result1==
"pm") $result.=
"ب.ظ";
else $result.=
"ق.ظ";
if($jday<
10)$result1=
"0".
$jday;
$result1=
date("D",$need);
if($result1==
"Thu") $result1=
"پ";
else if($result1==
"Sat") $result1=
"ش";
else if($result1==
"Sun") $result1=
"ى";
else if($result1==
"Mon") $result1=
"د";
else if($result1==
"Tue") $result1=
"س";
else if($result1==
"Wed") $result1=
"چ";
else if($result1==
"Thu") $result1=
"پ";
else if($result1==
"Fri") $result1=
"ج";
$result1=
date("g",$need);
$result1=
date("G",$need);
$result1=
date("h",$need);
$result1=
date("H",$need);
$result1=
date("i",$need);
$result1=
date("l",$need);
if($result1==
"Saturday") $result1=
"شنبه";
else if($result1==
"Sunday") $result1=
"يكشنبه";
else if($result1==
"Monday") $result1=
"دوشنبه";
else if($result1==
"Tuesday") $result1=
"سه شنبه";
else if($result1==
"Wednesday") $result1=
"چهارشنبه";
else if($result1==
"Thursday") $result1=
"پنجشنبه";
else if($result1==
"Friday") $result1=
"جمعه";
if($jmonth<
10) $result1=
"0".
$jmonth;
$result1=
date("s",$need);
$result.=
"ام";
$result.=
lastday ($month,$day,$year);
$result1=
date("w",$need);
/*if(lastday($tmp_month,$tmp_day,$tmp_year)=="31")
$subtypetemp=
substr($type,$i,1);
function jmaketime($hour=
"",$minute=
"",$second=
"",$jmonth=
"",$jday=
"",$jyear=
"")
if(!$hour &&
!$minute &&
!$second &&
!$jmonth &&
!$jmonth &&
!$jday &&
!$jyear)
$i=
mktime($hour,$minute,$second,$month,$day,$year);
///Find num of Day Begining Of Month ( 0 for Sat & 6 for Sun)
function mstart($month,$day,$year)
$timestamp=
mktime(0,0,0,$month,$day,$year);
return date("w",$timestamp);
//Find Number Of Days In This Month
function lastday ($month,$day,$year)
$lastdayen=
date("d",mktime(0,0,0,$month+
1,0,$year));
if($jdate2!=
"1") $lastdatep++
;
//Find days in this year untile now
for ($i=
1;$i<
$jmonth ||
$i==
12;$i++
)
$result+=
lastday($month,$day,$year);
//translate number of month to name of month
if($month==
"01") return "فروردين";
if($month==
"02") return "ارديبهشت";
if($month==
"03") return "خرداد";
if($month==
"04") return "تير";
if($month==
"05") return "مرداد";
if($month==
"06") return "شهريور";
if($month==
"07") return "مهر";
if($month==
"08") return "آبان";
if($month==
"09") return "آذر";
if($month==
"10") return "دي";
if($month==
"11") return "بهمن";
if($month==
"12") return "اسفند";
if($month==
"01") return "فرو";
if($month==
"02") return "ارد";
if($month==
"03") return "خرد";
if($month==
"04") return "تير";
if($month==
"05") return "مرد";
if($month==
"06") return "شهر";
if($month==
"07") return "مهر";
if($month==
"08") return "آبا";
if($month==
"09") return "آذر";
if($month==
"10") return "دي";
if($month==
"11") return "بهم";
if($month==
"12") return "اسف ";
////here convert to number in persian
for($sub=
0;$sub<
$len;$sub++
)
if(substr($srting,$sub,1)==
"0")$stringtemp.=
$num0;
elseif(substr($srting,$sub,1)==
"1")$stringtemp.=
$num1;
elseif(substr($srting,$sub,1)==
"2")$stringtemp.=
$num2;
elseif(substr($srting,$sub,1)==
"3")$stringtemp.=
$num3;
elseif(substr($srting,$sub,1)==
"4")$stringtemp.=
$num4;
elseif(substr($srting,$sub,1)==
"5")$stringtemp.=
$num5;
elseif(substr($srting,$sub,1)==
"6")$stringtemp.=
$num6;
elseif(substr($srting,$sub,1)==
"7")$stringtemp.=
$num7;
elseif(substr($srting,$sub,1)==
"8")$stringtemp.=
$num8;
elseif(substr($srting,$sub,1)==
"9")$stringtemp.=
$num9;
else $stringtemp.=
substr($srting,$sub,1);
}///end conver to number in persian
if($year%
4==
0 &&
$year%
100!=
0)
$j_days_in_month =
array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
if($month<=
12 &&
$month>
0)
if($j_days_in_month[$month-
1]>=
$day &&
$day>
0)
if(is_kabise($year) &&
$j_days_in_month[$month-
1]==
31)
"seconds"=>
jdate("s",$timestamp),
"minutes"=>
jdate("i",$timestamp),
"hours"=>
jdate("G",$timestamp),
"mday"=>
jdate("j",$timestamp),
"wday"=>
jdate("w",$timestamp),
"mon"=>
jdate("n",$timestamp),
"year"=>
jdate("Y",$timestamp),
"weekday"=>
jdate("l",$timestamp),
"month"=>
jdate("F",$timestamp),
// "jalali.php" is convertor to and from Gregorian and Jalali calendars.
// Copyright (C) 2000 Roozbeh Pournader and Mohammad Toossi
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// A copy of the GNU General Public License is available from:
// <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">http://www.gnu.org/copyleft/gpl.html</a>
$g_days_in_month =
array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$j_days_in_month =
array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
$g_day_no =
365*
$gy+
div($gy+
3,4)-
div($gy+
99,100)+
div($gy+
399,400);
for ($i=
0; $i <
$gm; ++
$i)
$g_day_no +=
$g_days_in_month[$i];
if ($gm>
1 &&
(($gy%
4==
0 &&
$gy%
100!=
0) ||
($gy%
400==
0)))
$j_day_no =
$g_day_no-
79;
$j_np =
div($j_day_no, 12053); /* 12053 = 365*33 + 32/4 */
$j_day_no =
$j_day_no %
12053;
$jy =
979+
33*
$j_np+
4*
div($j_day_no,1461); /* 1461 = 365*4 + 4/4 */
$jy +=
div($j_day_no-
1, 365);
$j_day_no =
($j_day_no-
1)%
365;
for ($i =
0; $i <
11 &&
$j_day_no >=
$j_days_in_month[$i]; ++
$i)
$j_day_no -=
$j_days_in_month[$i];
return array($jy, $jm, $jd);
$g_days_in_month =
array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$j_days_in_month =
array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
$j_day_no =
365*
$jy +
div($jy, 33)*
8 +
div($jy%
33+
3, 4);
for ($i=
0; $i <
$jm; ++
$i)
$j_day_no +=
$j_days_in_month[$i];
$g_day_no =
$j_day_no+
79;
$gy =
1600 +
400*
div($g_day_no, 146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */
$g_day_no =
$g_day_no %
146097;
if ($g_day_no >=
36525) /* 36525 = 365*100 + 100/4 */
$gy +=
100*
div($g_day_no, 36524); /* 36524 = 365*100 + 100/4 - 100/100 */
$g_day_no =
$g_day_no %
36524;
$gy +=
4*
div($g_day_no, 1461); /* 1461 = 365*4 + 4/4 */
$gy +=
div($g_day_no, 365);
$g_day_no =
$g_day_no %
365;
for ($i =
0; $g_day_no >=
$g_days_in_month[$i] +
($i ==
1 &&
$leap); $i++
)
$g_day_no -=
$g_days_in_month[$i] +
($i ==
1 &&
$leap);
return array($gy, $gm, $gd);
function mlj($date){ //for find jmaketime date
global $mosConfig_offset;
//split 0000-00-00 00:00:00
if(ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})",$date,$arg)){
}elseif (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})",$date,$arg)){ //split 0000-00-00
$mdate =
jmaketime($hour,$min,$sec,$mon,$day,$year)-
($mosConfig_offset *
60 *
60);
Documentation generated on Mon, 05 May 2008 16:19:13 +0400 by phpDocumentor 1.4.0